package com.nys.cqhttp.util;

import java.util.Properties;

import org.springframework.beans.factory.config.YamlPropertiesFactoryBean;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;

/**
 * PropertiesUtils
 *
 * @author nysheng
 * @version 1.0.0
 * @description 配置属性工具类
 * @date 2022/1/17 13:37
 */
public class PropertiesUtils {
    private static String PROPERTY_NAME = "application.yml";

    public static Object getStrYmlVal(Object key){
        Resource resource = new ClassPathResource(PROPERTY_NAME);
        Properties properties = null;
        try {
            YamlPropertiesFactoryBean yamlFactory = new YamlPropertiesFactoryBean();
            yamlFactory.setResources(resource);
            properties =  yamlFactory.getObject();
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
        return properties.get(key);
    }
}
